//
// Created by longyunbo on 6/23/21.
//


#define PropertyBuilderByName(type, name, access_permission)\
    access_permission:\
        type m_##name;\
    public:\
    inline void set##name(type v) {\
        m_##name = v;\
    }\
    inline type get##name() {\
        return m_##name;\
    }\

#define PointerPropertyBuilderByName(type, name, access_permission)\
    access_permission:\
        type* m_##name;\
    public:\
        inline void set##name(type* v){\
            m_##name = v;\
        }\
        inline type* get##name(){\
            return m_##name;\
}\

#ifndef ANALYSIS_INSTANCEKLASS_H
#define ANALYSIS_INSTANCEKLASS_H
#include "Klass.h"
#include "ConstantPool.h"
#include <list>
#include "InterfaceInfo.h"
#include "FieldInfo.h"
#include "MethodInfo.h"
#include "AttributeInfo.h"
#include "string"


using namespace std;

class InstanceKlass : Klass {

private:

    //魔术
    int _magic;
public:
    void set_magic( int value );
    int get_magic();


    //主版本
    short major;
    PropertyBuilderByName(short,major,public);


    //次版本
    short minor;
    PropertyBuilderByName(short,minor,public);

    //常量池
    ConstantPool* _constantPool;
    ConstantPool* get_constantPool();
    void set_constantPool(ConstantPool* value);

    //类的权限标识符号
    int accessFlags;
    PropertyBuilderByName(short,accessFlags,public);

    //当前类名下标
    int thisClassIndex;
    PropertyBuilderByName(short,thisClassIndex,public);

    //当前类名
    long thisClassName;
    PropertyBuilderByName(long,thisClassName,public);

    //父类名字下标
    int superClassIndex;
    PropertyBuilderByName(short,superClassIndex,public);

    //父类的名字
    long superClassName;
    PropertyBuilderByName(long,superClassName,public);

    //接口的数量
    int interfaceLength;
    PropertyBuilderByName(short,interfaceLength,public);

    //接口集合
    list<InterfaceInfo*> interfaceInfo;
    list<InterfaceInfo*> getInterfaceInfo();
    void setInterfaceInfo( list<InterfaceInfo*> value );

    //属性长度
    short fileLength;
    PropertyBuilderByName(short,fileLength,public);

    //属性集合
    list<FieldInfo*> fieldInfo;
    list<FieldInfo*> getFieldInfo();
    void setFieldInfo( list<FieldInfo*> value );

    //方法长度
    int methodLength;
    PropertyBuilderByName(short,methodLength,public);
    //方法
    MethodInfo* methodInfo;
    MethodInfo* getMethodInfo();
    void setMethodInfo(MethodInfo* methodInfo , int index );
    void initMethodInfo();


    //属性长度
    int attributeLength;

    //属性集合
    list<AttributeInfo> attributeInfos;

public:
    InstanceKlass();


public:
    ~InstanceKlass();
};


#endif //ANALYSIS_INSTANCEKLASS_H
